package primetest.dto;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import primetest.utils.StringUtils;



public class WardDto {
	private String key;
	private String name;
	private BuildingDto buildingDto;
	private int floor;
	private DepartmentDto departmentDto;
	private List<BedDto> bedDtos;
	private Boolean[] conditions;
	private String extraInfo;

	public int getBedCount() {
		return bedDtos.size();
	}
	public String getDepartmentName() {
		if (departmentDto != null) {
			return departmentDto.getName();
		} else {
			return "";
		}
	}

	public String getBuildingName() {
		if (buildingDto != null) {
			return buildingDto.getName();
		} else {
			return "";
		}
	}

	public List<BedDto> getBedDtos() {
		return bedDtos;
	}
	public void setBedDtos(List<BedDto> bedDtos) {
		this.bedDtos = bedDtos;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public BuildingDto getBuildingDto() {
		return buildingDto;
	}
	public void setBuildingDto(BuildingDto buildingDto) {
		this.buildingDto = buildingDto;
	}
	public int getFloor() {
		return floor;
	}
	public void setFloor(int floor) {
		this.floor = floor;
	}
	public DepartmentDto getDepartmentDto() {
		return departmentDto;
	}
	public void setDepartmentDto(DepartmentDto departmentDto) {
		this.departmentDto = departmentDto;
	}

	public Boolean[] getConditions() {
		return conditions;
	}
	public void setConditions(Boolean[] conditions) {
		this.conditions = conditions;
	}
	public String getExtraInfo() {
		return extraInfo;
	}
	public void setExtraInfo(String extraInfo) {
		this.extraInfo = extraInfo;
	}

	public WardDto() {
		key = UUID.randomUUID().toString();
	}
	public WardDto(String key, String name, BuildingDto buildingDto, int floor,
			DepartmentDto departmentDto, List<BedDto> bedDtos,
			Boolean[] conditions, String extraInfo) {
		super();
		this.key = key;
		this.name = name;
		this.buildingDto = buildingDto;
		this.floor = floor;
		this.departmentDto = departmentDto;
		this.bedDtos = bedDtos;
		this.conditions = conditions;
		this.extraInfo = extraInfo;
	}
	public String getBeds() {
		return StringUtils.join(":", bedDtos);
	}
	public String getBuildingKey() {
		if (buildingDto != null) {
			return buildingDto.getKey();
		} else {
			return "";
		}
	}

	public String getConditionsStr() {
		return StringUtils.join(":", conditions);
	}

	public int getDepartmentSeq() {
		if (departmentDto != null) {
			return departmentDto.getSeq();
		} else {
			return -1;
		}
	}

	public boolean isValid() {
		return true;
	}

	public void setAll(WardDto d) {
		this.key = d.key;
		this.name = d.name;
		this.buildingDto = d.buildingDto;
		this.floor = d.floor;
		this.departmentDto = d.departmentDto;
		this.bedDtos = new ArrayList<BedDto> (d.bedDtos);
		this.conditions = d.conditions.clone();
		this.extraInfo = d.extraInfo;
	}
}
